<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>安装ubuntu22.10</title>
    <meta name="generator" content="VuePress 1.9.9">
    <link href="https://cdn.jsdelivr.net/npm/@docsearch/css@alpha" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/@docsearch/js@alpha"></script>
    <meta name="description" content="">
    
    <link rel="preload" href="/my-note/assets/css/0.styles.6007a078.css" as="style"><link rel="preload" href="/my-note/assets/js/app.57cc677e.js" as="script"><link rel="preload" href="/my-note/assets/js/4.e47306be.js" as="script"><link rel="preload" href="/my-note/assets/js/1.48f7700a.js" as="script"><link rel="preload" href="/my-note/assets/js/14.df97c0c0.js" as="script"><link rel="prefetch" href="/my-note/assets/js/10.46acd53e.js"><link rel="prefetch" href="/my-note/assets/js/11.fe88a43b.js"><link rel="prefetch" href="/my-note/assets/js/12.48f4874d.js"><link rel="prefetch" href="/my-note/assets/js/13.23aed4ea.js"><link rel="prefetch" href="/my-note/assets/js/15.f24e80d9.js"><link rel="prefetch" href="/my-note/assets/js/16.d95b4dc2.js"><link rel="prefetch" href="/my-note/assets/js/17.75e0c72c.js"><link rel="prefetch" href="/my-note/assets/js/18.c3530f0f.js"><link rel="prefetch" href="/my-note/assets/js/19.7e2b6798.js"><link rel="prefetch" href="/my-note/assets/js/20.2c5cc0c8.js"><link rel="prefetch" href="/my-note/assets/js/21.cdd9522e.js"><link rel="prefetch" href="/my-note/assets/js/22.d092f66f.js"><link rel="prefetch" href="/my-note/assets/js/23.0c445dc8.js"><link rel="prefetch" href="/my-note/assets/js/24.955d42c4.js"><link rel="prefetch" href="/my-note/assets/js/25.bc3fab3a.js"><link rel="prefetch" href="/my-note/assets/js/26.fdb157a6.js"><link rel="prefetch" href="/my-note/assets/js/27.8dd07a3b.js"><link rel="prefetch" href="/my-note/assets/js/28.38ca7c9c.js"><link rel="prefetch" href="/my-note/assets/js/29.e9495e42.js"><link rel="prefetch" href="/my-note/assets/js/3.04dff26a.js"><link rel="prefetch" href="/my-note/assets/js/30.adee5af1.js"><link rel="prefetch" href="/my-note/assets/js/31.da43303d.js"><link rel="prefetch" href="/my-note/assets/js/32.9aed0f05.js"><link rel="prefetch" href="/my-note/assets/js/33.827d2ad3.js"><link rel="prefetch" href="/my-note/assets/js/34.fca2e8d8.js"><link rel="prefetch" href="/my-note/assets/js/5.7044c00d.js"><link rel="prefetch" href="/my-note/assets/js/6.2d88e74d.js"><link rel="prefetch" href="/my-note/assets/js/7.bbf0a4a6.js"><link rel="prefetch" href="/my-note/assets/js/8.b0ccbd7f.js"><link rel="prefetch" href="/my-note/assets/js/9.f3dabe1a.js">
    <link rel="stylesheet" href="/my-note/assets/css/0.styles.6007a078.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar" data-v-7dd95ae2><div data-v-7dd95ae2><div class="password-shadow password-wrapper-out" style="display:none;" data-v-59e6cb88 data-v-7dd95ae2 data-v-7dd95ae2><h3 class="title" data-v-59e6cb88></h3> <p class="description" data-v-59e6cb88></p> <label id="box" class="inputBox" data-v-59e6cb88><input type="password" value="" data-v-59e6cb88> <span data-v-59e6cb88>Konck! Knock!</span> <button data-v-59e6cb88>OK</button></label> <div class="footer" data-v-59e6cb88><span data-v-59e6cb88><i class="iconfont reco-theme" data-v-59e6cb88></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-59e6cb88>vuePress-theme-reco</a></span> <span data-v-59e6cb88><i class="iconfont reco-copyright" data-v-59e6cb88></i> <a data-v-59e6cb88><!---->
          
        <!---->
        2023
      </a></span></div></div> <div class="hide" data-v-7dd95ae2><header class="navbar" data-v-7dd95ae2><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/my-note/" class="home-link router-link-active"></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my-note/" class="nav-link"><i class="undefined"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="undefined"></i>
      Code
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my-note/code/vuepress-first/" class="nav-link"><i class="undefined"></i>
  vuepress-first
</a></li><li class="dropdown-item"><!----> <a href="/my-note/code/github-gitee/" class="nav-link"><i class="undefined"></i>
  github-gitee
</a></li><li class="dropdown-item"><!----> <a href="/my-note/code/create-ssh-key-github-to-gitee/" class="nav-link"><i class="undefined"></i>
  create-ssh-key-github-to-gitee
</a></li><li class="dropdown-item"><!----> <a href="/my-note/code/Algolia-full-search/" class="nav-link"><i class="undefined"></i>
  Algolia-full-search
</a></li><li class="dropdown-item"><!----> <a href="/my-note/code/dependencies-inject/" class="nav-link"><i class="undefined"></i>
  dependencies-inject
</a></li><li class="dropdown-item"><!----> <a href="/my-note/project/email/" class="nav-link"><i class="undefined"></i>
  project
</a></li></ul></div></div><div class="nav-item"><a href="/my-note/life/" class="nav-link"><i class="undefined"></i>
  Life
</a></div><div class="nav-item"><a href="/my-note/Car/" class="nav-link"><i class="undefined"></i>
  Car
</a></div><div class="nav-item"><a href="/my-note/note/" class="nav-link"><i class="undefined"></i>
  Note
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="undefined"></i>
      pa-note
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my-note/pa-note/1-env/" class="nav-link"><i class="undefined"></i>
  1-env
</a></li><li class="dropdown-item"><!----> <a href="/my-note/pa-note/2-env/" class="nav-link"><i class="undefined"></i>
  2-env
</a></li><li class="dropdown-item"><!----> <a href="/my-note/pa-note/3-pa-env/" class="nav-link"><i class="undefined"></i>
  3-pa-env
</a></li></ul></div></div><div class="nav-item"><a href="/my-note/problem/" class="nav-link"><i class="undefined"></i>
  Problem
</a></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-7dd95ae2></div> <aside class="sidebar" data-v-7dd95ae2><div class="personal-info-wrapper" data-v-1fad0c41 data-v-7dd95ae2><!----> <!----> <div class="num" data-v-1fad0c41><div data-v-1fad0c41><h3 data-v-1fad0c41>20</h3> <h6 data-v-1fad0c41>Articles</h6></div> <div data-v-1fad0c41><h3 data-v-1fad0c41>0</h3> <h6 data-v-1fad0c41>Tags</h6></div></div> <ul class="social-links" data-v-1fad0c41></ul> <hr data-v-1fad0c41></div> <nav class="nav-links"><div class="nav-item"><a href="/my-note/" class="nav-link"><i class="undefined"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="undefined"></i>
      Code
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my-note/code/vuepress-first/" class="nav-link"><i class="undefined"></i>
  vuepress-first
</a></li><li class="dropdown-item"><!----> <a href="/my-note/code/github-gitee/" class="nav-link"><i class="undefined"></i>
  github-gitee
</a></li><li class="dropdown-item"><!----> <a href="/my-note/code/create-ssh-key-github-to-gitee/" class="nav-link"><i class="undefined"></i>
  create-ssh-key-github-to-gitee
</a></li><li class="dropdown-item"><!----> <a href="/my-note/code/Algolia-full-search/" class="nav-link"><i class="undefined"></i>
  Algolia-full-search
</a></li><li class="dropdown-item"><!----> <a href="/my-note/code/dependencies-inject/" class="nav-link"><i class="undefined"></i>
  dependencies-inject
</a></li><li class="dropdown-item"><!----> <a href="/my-note/project/email/" class="nav-link"><i class="undefined"></i>
  project
</a></li></ul></div></div><div class="nav-item"><a href="/my-note/life/" class="nav-link"><i class="undefined"></i>
  Life
</a></div><div class="nav-item"><a href="/my-note/Car/" class="nav-link"><i class="undefined"></i>
  Car
</a></div><div class="nav-item"><a href="/my-note/note/" class="nav-link"><i class="undefined"></i>
  Note
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="undefined"></i>
      pa-note
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my-note/pa-note/1-env/" class="nav-link"><i class="undefined"></i>
  1-env
</a></li><li class="dropdown-item"><!----> <a href="/my-note/pa-note/2-env/" class="nav-link"><i class="undefined"></i>
  2-env
</a></li><li class="dropdown-item"><!----> <a href="/my-note/pa-note/3-pa-env/" class="nav-link"><i class="undefined"></i>
  3-pa-env
</a></li></ul></div></div><div class="nav-item"><a href="/my-note/problem/" class="nav-link"><i class="undefined"></i>
  Problem
</a></div> <!----></nav> <!----> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-59e6cb88 data-v-7dd95ae2><h3 class="title" data-v-59e6cb88></h3> <!----> <label id="box" class="inputBox" data-v-59e6cb88><input type="password" value="" data-v-59e6cb88> <span data-v-59e6cb88>Konck! Knock!</span> <button data-v-59e6cb88>OK</button></label> <div class="footer" data-v-59e6cb88><span data-v-59e6cb88><i class="iconfont reco-theme" data-v-59e6cb88></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-59e6cb88>vuePress-theme-reco</a></span> <span data-v-59e6cb88><i class="iconfont reco-copyright" data-v-59e6cb88></i> <a data-v-59e6cb88><!---->
          
        <!---->
        2023
      </a></span></div></div> <div data-v-7dd95ae2><div data-v-7dd95ae2><main class="page"><section style="display:;"><div class="page-title"><h1 class="title">安装ubuntu22.10</h1> <div data-v-8a445198><!----> <!----> <i class="iconfont reco-eye" data-v-8a445198><span id="/my-note/pa-note/1-env.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-8a445198><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <!----></div></div> <div class="theme-reco-content content__default"><h1 id="安装ubuntu22-10"><a href="#安装ubuntu22-10" class="header-anchor">#</a> 安装ubuntu22.10</h1> <h2 id="下载地址"><a href="#下载地址" class="header-anchor">#</a> 下载地址</h2> <p><a href="https://mirrors.ustc.edu.cn/ubuntu-releases/" target="_blank" rel="noopener noreferrer">中科大源<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://mirrors.aliyun.com/ubuntu-releases/" target="_blank" rel="noopener noreferrer">阿里云开源镜像站<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h2 id="在ubuntu-20-04-lts上安装vmware-tools"><a href="#在ubuntu-20-04-lts上安装vmware-tools" class="header-anchor">#</a> 在Ubuntu 20.04 LTS上安装VMware Tools</h2> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>
<span class="token function">sudo</span> <span class="token function">apt</span> update
<span class="token function">sudo</span> <span class="token function">apt</span> upgrade
<span class="token function">sudo</span> <span class="token function">apt</span> <span class="token function">install</span> open-vm-tools
<span class="token comment"># 运行 Ubuntu Desktop 安装下面这个</span>
<span class="token function">sudo</span> <span class="token function">apt</span> <span class="token function">install</span> open-vm-tools-desktop
<span class="token function">sudo</span> <span class="token function">reboot</span>

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h2 id="虚拟机复制粘贴"><a href="#虚拟机复制粘贴" class="header-anchor">#</a> 虚拟机复制粘贴</h2> <p>1、虚拟机关机</p> <p>2、
<img src="/my-note/assets/img/env-1.d754f5d5.png" alt="env-1.png"> <img src="/my-note/assets/img/env-2.61a3f3e4.png" alt="env-1.png"></p> <h2 id="换源"><a href="#换源" class="header-anchor">#</a> 换源</h2> <p>要在 Ubuntu 22.10 中使用中科大的源，可以按照以下步骤操作：</p> <ol><li><p>打开终端
在 Ubuntu 中，可以使用快捷键 Ctrl + Alt + T 打开终端。</p></li> <li><p>备份原有源列表
在更改下载源之前，最好备份原有源列表。可以使用以下命令备份：</p></li></ol> <div class="language- line-numbers-mode"><pre class="language-text"><code>sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ol start="3"><li>编辑源列表
使用以下命令打开源列表文件：</li></ol> <div class="language- line-numbers-mode"><pre class="language-text"><code>sudo nano /etc/apt/sources.list
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ol start="4"><li>添加源</li></ol> <div class="language- line-numbers-mode"><pre class="language-text"><code>#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
#添加清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br></div></div><ol start="5"><li><p>保存文件并退出
在完成编辑后，按 Ctrl + X 键，然后按 Y 键保存更改。</p></li> <li><p>更新下载源
可以使用以下命令更新下载源：</p></li></ol> <div class="language- line-numbers-mode"><pre class="language-text"><code>sudo apt-get update
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ol start="7"><li>安装软件包
更改下载源后，可以使用以下命令安装软件包：</li></ol> <div class="language- line-numbers-mode"><pre class="language-text"><code>sudo apt-get install 软件包名称
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>以上是在 Ubuntu 22.10 中使用中科大的源的步骤。请注意，中科大的源可能不是官方源，使用前请确保可靠性。</p> <h2 id="vim-选中连续的行-在开头添加"><a href="#vim-选中连续的行-在开头添加" class="header-anchor">#</a> vim 选中连续的行，在开头添加#</h2> <p>sudo
1、ctrl + v</p> <p>2、j / k 上下选择</p> <p>3、shift + i(小写)</p> <p>4、输入字符</p> <h2 id="ssh-连接"><a href="#ssh-连接" class="header-anchor">#</a> ssh 连接</h2> <p>要在 VM 虚拟机中的 Ubuntu 上启用 SSH，可以按照以下步骤进行操作：</p> <ol><li>安装 SSH 服务器
在 Ubuntu 终端中，使用以下命令安装 SSH 服务器：</li></ol> <div class="language- line-numbers-mode"><pre class="language-text"><code>sudo apt-get update
sudo apt install ssh
sudo apt-get install openssh-server
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ol start="2"><li>配置 SSH 服务器
安装完成后，使用以下命令打开 SSH 服务器配置文件：</li></ol> <div class="language- line-numbers-mode"><pre class="language-text"><code>sudo nano /etc/ssh/sshd_config
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>在文件中找到以下行：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>将其中的 <code>#Port 22</code> 的注释符号 # 去掉，并将端口号改为自己想要的端口号（例如 2222），如下所示：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>Port 2222
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><ol start="3"><li>重启 SSH 服务器 使用以下命令重启 SSH 服务器：</li></ol> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>
<span class="token function">sudo</span> ufw allow <span class="token function">ssh</span>

<span class="token function">sudo</span> <span class="token function">service</span> <span class="token function">ssh</span> restart

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ol start="4"><li>查看是否启动</li></ol> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> systemctl status <span class="token function">ssh</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ol start="5"><li>测试本机连接</li></ol> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">ssh</span> username@ip_address
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ol start="6"><li>测试局域网连接</li></ol> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">ssh</span> username@ip_address
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="配置静态ip地址-使用yaml"><a href="#配置静态ip地址-使用yaml" class="header-anchor">#</a> 配置静态ip地址，使用yaml</h2> <p>1、</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">ip</span> addr

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="language-shell line-numbers-mode"><pre class="language-shell"><code>
<span class="token number">1</span>: lo: <span class="token operator">&lt;</span>LOOPBACK,UP,LOWER_UP<span class="token operator">&gt;</span> mtu <span class="token number">65536</span> qdisc noqueue state UNKNOWN group default qlen <span class="token number">1000</span>
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet <span class="token number">127.0</span>.0.1/8 scope <span class="token function">host</span> lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope <span class="token function">host</span> 
       valid_lft forever preferred_lft forever
<span class="token number">2</span>: ens33: <span class="token operator">&lt;</span>BROADCAST,MULTICAST,UP,LOWER_UP<span class="token operator">&gt;</span> mtu <span class="token number">1500</span> qdisc fq_codel state UP group default qlen <span class="token number">1000</span>
    link/ether 00:0c:29:b7:1c:3d brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet <span class="token number">192.168</span>.31.170/24 brd <span class="token number">192.168</span>.31.255 scope global dynamic noprefixroute ens33
       valid_lft 40629sec preferred_lft 40629sec
    inet6 fe80::fc6c:f590:a8f:5ef4/64 scope <span class="token function">link</span> noprefixroute 
       valid_lft forever preferred_lft forever
       
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><p>2、配置 yaml</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>
<span class="token function">sudo</span> <span class="token function">vim</span> /etc/netplan/01-network-manager-all.yaml

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token comment"># Let NetworkManager manage all devices on this system</span>
network:
  version: <span class="token number">2</span>
  renderer: NetworkManager
<span class="token comment">#  增加下面的网卡</span>
  ethernets:
    enp2s1:
      dhcp4: <span class="token boolean">false</span>
      dhcp6: <span class="token boolean">false</span>
      addresses:
        - <span class="token number">192.168</span>.31.170/24
      routes:
        - to: default
          via: <span class="token number">192.168</span>.31.1
      nameservers:
          addresses: <span class="token punctuation">[</span><span class="token number">8.8</span>.8.8, <span class="token number">1.1</span>.1.1<span class="token punctuation">]</span>

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><p>3、重启网卡</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> netplan apply
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>4、查看ip</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>
<span class="token function">ip</span> addr

<span class="token number">1</span>: lo: <span class="token operator">&lt;</span>LOOPBACK,UP,LOWER_UP<span class="token operator">&gt;</span> mtu <span class="token number">65536</span> qdisc noqueue state UNKNOWN group default qlen <span class="token number">1000</span>
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet <span class="token number">127.0</span>.0.1/8 scope <span class="token function">host</span> lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope <span class="token function">host</span> 
       valid_lft forever preferred_lft forever
<span class="token number">2</span>: ens33: <span class="token operator">&lt;</span>BROADCAST,MULTICAST,UP,LOWER_UP<span class="token operator">&gt;</span> mtu <span class="token number">1500</span> qdisc fq_codel state UP group default qlen <span class="token number">1000</span>
    link/ether 00:0c:29:b7:1c:3d brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet <span class="token number">192.168</span>.31.170/24 brd <span class="token number">192.168</span>.31.255 scope global dynamic noprefixroute ens33
       valid_lft 40219sec preferred_lft 40219sec
    inet <span class="token number">192.168</span>.31.171/24 brd <span class="token number">192.168</span>.31.255 scope global secondary dynamic noprefixroute ens33
       valid_lft 43068sec preferred_lft 43068sec
    inet <span class="token number">192.168</span>.31.172/24 brd <span class="token number">192.168</span>.31.255 scope global secondary dynamic noprefixroute ens33
       valid_lft 43193sec preferred_lft 43193sec
    inet6 fe80::fc6c:f590:a8f:5ef4/64 scope <span class="token function">link</span> noprefixroute 
       valid_lft forever preferred_lft forever

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div></div></section> <footer class="page-edit"><!----> <!----></footer> <!----> <div class="comments-wrapper"><!----></div></main></div> <!----></div> <ul class="sub-sidebar sub-sidebar-wrapper" style="width:12rem;" data-v-b57cc07c data-v-7dd95ae2><li class="level-2" data-v-b57cc07c><a href="/my-note/pa-note/1-env.html#下载地址" class="sidebar-link reco-side-下载地址" data-v-b57cc07c>下载地址</a></li><li class="level-2" data-v-b57cc07c><a href="/my-note/pa-note/1-env.html#在ubuntu-20-04-lts上安装vmware-tools" class="sidebar-link reco-side-在ubuntu-20-04-lts上安装vmware-tools" data-v-b57cc07c>在Ubuntu 20.04 LTS上安装VMware Tools</a></li><li class="level-2" data-v-b57cc07c><a href="/my-note/pa-note/1-env.html#虚拟机复制粘贴" class="sidebar-link reco-side-虚拟机复制粘贴" data-v-b57cc07c>虚拟机复制粘贴</a></li><li class="level-2" data-v-b57cc07c><a href="/my-note/pa-note/1-env.html#换源" class="sidebar-link reco-side-换源" data-v-b57cc07c>换源</a></li><li class="level-2" data-v-b57cc07c><a href="/my-note/pa-note/1-env.html#vim-选中连续的行-在开头添加" class="sidebar-link reco-side-vim-选中连续的行-在开头添加" data-v-b57cc07c>vim 选中连续的行，在开头添加#</a></li><li class="level-2" data-v-b57cc07c><a href="/my-note/pa-note/1-env.html#ssh-连接" class="sidebar-link reco-side-ssh-连接" data-v-b57cc07c>ssh 连接</a></li><li class="level-2" data-v-b57cc07c><a href="/my-note/pa-note/1-env.html#配置静态ip地址-使用yaml" class="sidebar-link reco-side-配置静态ip地址-使用yaml" data-v-b57cc07c>配置静态ip地址，使用yaml</a></li></ul></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div></div></div>
    <script src="/my-note/assets/js/app.57cc677e.js" defer></script><script src="/my-note/assets/js/4.e47306be.js" defer></script><script src="/my-note/assets/js/1.48f7700a.js" defer></script><script src="/my-note/assets/js/14.df97c0c0.js" defer></script>
  </body>
</html>
